package com.amos.muexamcore.util;

import lombok.extern.slf4j.Slf4j;

/**
 * Copyright © 2018 嘉源锐信. All rights reserved.
 *
 * @Project: mu-exam
 * @ClassName: AddressUtils
 * @Package: com.amos.util
 * @author: zhuqb
 * @Description:
 * @date: 2020/3/25 0025 下午 15:58
 * @Version: V1.0
 */
@Slf4j
public class AddressUtils {

    public static final String IP_URL = "http://ip.taobao.com/service/getIpInfo.php";

    public static String getRealAddressByIP(String ip) {
        String address = "XX XX";
        // 内网不查询
        if (IpUtils.internalIp(ip)) {
            return "内网IP";
        }
//        if (RuoYiConfig.isAddressEnabled()) {
//            String rspStr = HttpUtils.sendPost(IP_URL, "ip=" + ip);
//            if (StringUtils.isEmpty(rspStr)) {
//                log.error("获取地理位置异常 {}", ip);
//                return address;
//            }
//            JSONObject obj = JSONObject.parseObject(rspStr);
//            JSONObject data = obj.getObject("data", JSONObject.class);
//            String region = data.getString("region");
//            String city = data.getString("city");
//            address = region + " " + city;
//        }
        return address;
    }
}
